<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>多个ajax同时发送</title>
		<script src="news/js/ajax.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		
		<script>
			document.onclick = function(){
				let count = 0;
				let res1;
				let res2;
				// 第一个
				ajax({
					url:"ajax1.php",
					dataType:"json",
					success(res){
						console.log(res);
						res1 = res;
						count++;
						if(count==2){
							console.log(res1,res2);
						}
					}
				})
				
				// 第二个
				ajax({
					url:"ajax2.php",
					dataType:"json",
					success(res){
						console.log(res);
						res2 = res;
						count++;
						if(count==2){
							console.log(res1,res2);
						}
					}
				})
				
				
				// 2个都成功返还 
				console.log(1111);
				
			}
			
			
		
		</script>
	</body>
</html>
